Create charts for an economic comparison

This package also comes with utilities that allow you to create charts from the economy comparison operation. In this notebook, we’ll walk through them.

# First, set up the simulation

from policyengine import Simulation
from policyengine.outputs.macro.comparison.charts import *

sim = Simulation({
    "country": "uk",
    "scope": "macro",
    "reform": {
        "gov.hmrc.income_tax.allowances.personal_allowance.amount": 10_000,
    },
    "title": "Lowering the personal allowance to £10,000" # Required for charts
})

from policyengine.utils.charts import add_fonts

add_fonts() # Load the right font (Roboto Serif) in this notebook
/opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm

Budget

The budget chart shows high-level budget changes under the reform.

create_budget_comparison_chart(sim)

There is also the budget by program chart, which splits out the budgetary impact by program.

create_budget_program_comparison_chart(sim)

Decile

The decile chart shows the impact of the reform on each decile of the income distribution. You can specify whether this is over income deciles, or wealth deciles, in the UK.

create_decile_chart(sim, decile_variable="income", relative=True)

Winners and losers

The winners and losers chart shows in each decile (and overall) the share of people who come out ahead or behind under the reform. Again, you can specify whether the deciles are income or wealth in the UK.

create_winners_losers_chart(sim, decile_variable="income")

Poverty

The poverty chart shows the impact of the reform on various poverty rates, split out by demographic groups you can specify. You can show the change to poverty rate by age group, gender or racial group (US-only), and you can choose between regular or deep poverty.

create_poverty_chart(
    sim,
    age_group=None, # Specify None to show all age groups
    gender="all", # The rest are filters
    racial_group="all",
    rate_relative=False, # Compare how many people are in poverty rather than the rate
    change_relative=False, # Compare the absolute headcount rather than % change
    poverty_rate="regular",
)

Inequality

The inequality chart shows the impact of the reform on various inequality measures: the Gini coefficient, the share of income held by the top 10% of households (by income) and the top 1% share.

create_inequality_chart(sim, relative=True)

Labor supply

The labor supply chart shows the impact of the reform on labor supply if labor supply response assumptions have been set in the reform, split out by groups you can specify. You can show the change to labor supply by decile, the mechanism (or elasticity- e.g. filtering to only substitution effect-powered responses), and also by the unit (hours or earnings, though only earnings in the UK).

sim = Simulation({
    "country": "uk",
    "scope": "macro",
    "reform": {
        "gov.hmrc.income_tax.allowances.personal_allowance.amount": 10_000,
        "gov.simulation.labor_supply_responses.substitution_elasticity": 0.2,
    },
    "title": "Lowering the personal allowance to £10,000" # Required for charts
})

create_labor_supply_chart(
    sim,
    decile=None,
    elasticity="all",
    unit="earnings",
    change_relative=True,
    change_average=False,
)